package net.hvacapp.cmvrfforandroid.ui.project;

import android.app.AlertDialog;
import android.app.Dialog;
import android.content.ActivityNotFoundException;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.location.Address;
import android.location.Criteria;
import android.location.Geocoder;
import android.location.Location;
import android.location.LocationManager;
import android.os.Bundle;
import android.provider.Settings;
import android.view.View;
import android.widget.EditText;
import android.widget.LinearLayout;

import com.mirror.android.common.util.StringUtils;

import net.hvacapp.cmvrfforandroid.AppManager;
import net.hvacapp.cmvrfforandroid.R;
import net.hvacapp.cmvrfforandroid.http.BasicHttpClient;
import net.hvacapp.cmvrfforandroid.http.HttpCallbackHandle;
import net.hvacapp.cmvrfforandroid.http.HttpConstant;
import net.hvacapp.cmvrfforandroid.manager.AccountManager;
import net.hvacapp.cmvrfforandroid.manager.ProjectManager;
import net.hvacapp.cmvrfforandroid.ui.BaseActivity;
import net.hvacapp.cmvrfforandroid.ui.EventBus.ProjectListRefreshEvent;
import net.hvacapp.cmvrfforandroid.ui.MainTabBarActivity;
import net.hvacapp.cmvrfforandroid.ui.project.model.GetCityGuidResp;
import net.hvacapp.cmvrfforandroid.ui.project.model.GetProjectInfoDataResp;
import net.hvacapp.cmvrfforandroid.ui.project.model.ProjectInfoData;
import net.hvacapp.cmvrfforandroid.ui.selections.SelectionCityActivity;
import net.hvacapp.cmvrfforandroid.ui.selections.SelectionNationActivity;
import net.hvacapp.cmvrfforandroid.ui.selections.SelectionProvinceActivity;
import net.hvacapp.cmvrfforandroid.ui.selections.model.AreaData;
import net.hvacapp.cmvrfforandroid.utils.AnnotationUtil;
import net.hvacapp.cmvrfforandroid.utils.NumberUtil;
import net.hvacapp.cmvrfforandroid.widget.GroupSelectionView;
import net.hvacapp.cmvrfforandroid.widget.ProjectActionView;
import net.hvacapp.cmvrfforandroid.widget.UserSelectionView;

import org.androidannotations.annotations.AfterViews;
import org.androidannotations.annotations.EActivity;
import org.androidannotations.annotations.ViewById;

import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import de.greenrobot.event.EventBus;

@EActivity(R.layout.activity_project_step1)
public class ProjectStep1Activity extends BaseActivity {

    private final int Select_Nation = 1;
    private final int Select_Province = 2;
    private final int Select_City = 3;


    @ViewById(R.id.action_view)
    ProjectActionView mActionView;

    @ViewById(R.id.group_area)
    GroupSelectionView mAreaGroup;

    @ViewById(R.id.ll_area_section)
    LinearLayout mAreaSectionLl;
    @ViewById(R.id.sel_nation)
    UserSelectionView mNationSel;
    @ViewById(R.id.sel_province)
    UserSelectionView mProvinceSel;
    @ViewById(R.id.sel_city)
    UserSelectionView mCitySel;

    @ViewById(R.id.sel_dfr)
    UserSelectionView mDfrSel;
    @ViewById(R.id.sel_power)
    UserSelectionView mPowerSel;

    @ViewById(R.id.cet_house)
    EditText mHouseCet;
    @ViewById(R.id.cet_area)
    EditText mAreaCet;
    @ViewById(R.id.cet_name)
    EditText mNameCet;
    @ViewById(R.id.cet_phone)
    EditText mPhoneCet;
    @ViewById(R.id.cet_qq)
    EditText mQQCet;
    @ViewById(R.id.cet_wechar)
    EditText mWecharCet;
    @ViewById(R.id.cet_email)
    EditText mEmailCet;



    private ArrayList<AreaData> mSelectedNation;
    private ArrayList<AreaData> mSelectedProvince;
    private ArrayList<AreaData> mSelectedCity;

    private int mDfrType = 0;
    private int mPowerType = 0;

    private Dialog mProgressDlg;


    /**
     * 页面加载完后执行
     */
    @AfterViews
    @Override
    protected void viewDidLoad() {
        super.viewDidLoad();
        if (StringUtils.isEmpty(ProjectManager.getInstance().getProjectData().getCityId())) {
            //没有城市信息时，打开gps去定位获取城市
            openGPSSettings();
        }
        initViews();
        initEvent();
    }

    /***
     * 初始化视图
     */
    private void initViews() {
        mActionView.setActionInfo(ProjectManager.getInstance().getTotal(), ProjectManager.getInstance().getCurrent());
        mAreaGroup.setTitleString("项目地点");
        mNationSel.setTitleString("选择经营国家");
        mProvinceSel.setTitleString("选择经营省份");
        mCitySel.setTitleString("选择经营城市");
        mDfrSel.setTitleString("选择电辅热类型");
        mPowerSel.setTitleString("选择电源类型");

        AreaData defaultNation = AppManager.getAppManager().getmDefaultNation();
        if (defaultNation != null) {
            mSelectedNation = new ArrayList<>();
            mSelectedNation.add(defaultNation);
            mNationSel.setInfoString(defaultNation.getName());
        }

        ProjectInfoData project = ProjectManager.getInstance().getProjectData();
        if (!StringUtils.isEmpty(project.getCityId())) {
            getCityByGuid(project.getCityId());
        }
        mHouseCet.setText(project.getHouse());
        if (project.getArea() > 0) {
            mAreaCet.setText(NumberUtil.formateDouble(project.getArea()));
        }

        mDfrType = project.getDfrType();
        if (mDfrType == 1) {
            mDfrSel.setInfoString("带电辅热");
        }
        else if (mDfrType == 2) {
            mDfrSel.setInfoString("不带电辅热");
        }
        else {
            mDfrType = 3;
            mDfrSel.setInfoString("全部设备");
        }

        mPowerType = project.getPowerType();
        if (project.getPowerType() == 1) {
            mPowerSel.setInfoString("220V");
        }
        else if (project.getPowerType() == 2) {
            mPowerSel.setInfoString("380V");
        }
        else {
            mPowerType = 3;
            mPowerSel.setInfoString("全部设备");
        }

        mNameCet.setText(project.getOwnerName());
        mPhoneCet.setText(project.getOwnerContact());
        mQQCet.setText(project.getOwnerQQ());
        mWecharCet.setText(project.getOwnerWeChar());
        mEmailCet.setText(project.getOwnerEmail());
    }

    /**
     * 初始化
     */
    @Override
    public void initBoot() {
        setupToolbar(R.string.title_for_project, "基本信息", new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                startActivity(AnnotationUtil.get(MainTabBarActivity.class));
            }
        });
    }

    /**
     * 初始化数据
     */
    @Override
    public void initData(Intent intent) {
        ProjectManager.getInstance().initData();
    }

    /**
     * 页面名称
     */
    @Override
    public String getName() {
        return "";
    }

    private void initEvent() {
        mActionView.setLeftOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                //上一步
            }
        });

        mActionView.setRightOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                //下一步
                if (!projectInfoIsOk()) {
                    return;
                }

                if (!projectInfoIsModified()) {
                    //直接到下一步的Activity
                    ProjectManager.getInstance().goNextStep();
                    if (ProjectManager.getInstance().isBindTemplate()) {
                        startActivity(AnnotationUtil.get(ProjectStep3Activity.class));
                    }
                    else {
                        startActivity(AnnotationUtil.get(ProjectStep2Activity.class));
                    }
                    return;
                }
                if (ProjectManager.getInstance().getStatus() == ProjectManager.PROJECT_STATUS_NEW) {
                    createProject();
                }
                else {
                    modifyProject();
                }

            }
        });

        mAreaGroup.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                if (mAreaSectionLl.getVisibility() == View.VISIBLE) {
                    mAreaSectionLl.setVisibility(View.GONE);
                    mAreaGroup.setGroupVisible(false);
                } else {
                    mAreaSectionLl.setVisibility(View.VISIBLE);
                    mAreaGroup.setGroupVisible(true);
                }
            }
        });

        mNationSel.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent = new Intent(ProjectStep1Activity.this, AnnotationUtil.get(SelectionNationActivity.class));
                Bundle bundle = new Bundle();
                bundle.putParcelableArrayList("nation", mSelectedNation);
                bundle.putBoolean("multiple", false);
                intent.putExtras(bundle);
                startActivityForResult(intent, Select_Nation);
            }
        });

        mProvinceSel.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                if (mSelectedNation == null || mSelectedNation.size() == 0) {
                    showMessage("请先选择国家！");
                } else {
                    Intent intent = new Intent(ProjectStep1Activity.this, AnnotationUtil.get(SelectionProvinceActivity.class));
                    Bundle bundle = new Bundle();
                    bundle.putParcelableArrayList("nation", mSelectedNation);
                    bundle.putParcelableArrayList("province", mSelectedProvince);
                    bundle.putBoolean("multiple", false);
                    intent.putExtras(bundle);
                    startActivityForResult(intent, Select_Province);
                }
            }
        });
        mCitySel.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                if (mSelectedProvince == null || mSelectedProvince.size() == 0) {
                    showMessage("请先选择省份！");
                }
                else {
                    Intent intent = new Intent(ProjectStep1Activity.this, AnnotationUtil.get(SelectionCityActivity.class));
                    Bundle bundle = new Bundle();
                    bundle.putParcelableArrayList("province", mSelectedProvince);
                    bundle.putParcelableArrayList("city", mSelectedCity);
                    bundle.putBoolean("multiple", false);
                    intent.putExtras(bundle);
                    startActivityForResult(intent, Select_City);
                }
            }
        });

        mDfrSel.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                //给定的换气量
                String[] items = ProjectStep1Activity.this.getResources().getStringArray(
                        R.array.DfrType);
                new AlertDialog.Builder(ProjectStep1Activity.this)
                        .setTitle("选择电辅热类型")
                        .setItems(items, new DialogInterface.OnClickListener() {

                            public void onClick(DialogInterface dialog,
                                                int which) {
                                mDfrType = which + 1;
                                if (mDfrType == 1) {
                                    mDfrSel.setInfoString("带电辅热");
                                }
                                else if (mDfrType == 2) {
                                    mDfrSel.setInfoString("不带电辅热");
                                }
                                else if (mDfrType == 3) {
                                    mDfrSel.setInfoString("全部设备");
                                }
                            }
                        })
                        .setNegativeButton("取消", new DialogInterface.OnClickListener() {
                            @Override
                            public void onClick(DialogInterface dialog, int which) {

                            }
                        })
                        .show();
            }
        });

        mPowerSel.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                //给定的换气量
                String[] items = ProjectStep1Activity.this.getResources().getStringArray(
                        R.array.PowserType);
                new AlertDialog.Builder(ProjectStep1Activity.this)
                        .setTitle("选择电源类型")
                        .setItems(items, new DialogInterface.OnClickListener() {

                            public void onClick(DialogInterface dialog,
                                                int which) {
                                mPowerType = which + 1;
                                if (mPowerType == 1) {
                                    mPowerSel.setInfoString("220V");
                                }
                                else if (mPowerType == 2) {
                                    mPowerSel.setInfoString("380V");
                                }
                                else if (mPowerType == 3) {
                                    mPowerSel.setInfoString("全部设备");
                                }
                            }
                        })
                        .setNegativeButton("取消", new DialogInterface.OnClickListener() {
                            @Override
                            public void onClick(DialogInterface dialog, int which) {

                            }
                        })
                        .show();
            }
        });
    }

    /**
     * 回调
     * @param requestCode
     * @param resultCode
     * @param data
     */
    @Override
    public void onActivityResult(int requestCode, int resultCode, Intent data) {
        if (resultCode != this.RESULT_OK) {
            return;
        }
        if (requestCode == Select_Nation) {
            if (data != null) {
                mSelectedNation = data.getParcelableArrayListExtra("nation");
                String selStr = "";
                if (mSelectedNation != null && mSelectedNation.size() > 0) {
                    for (AreaData item: mSelectedNation) {
                        selStr += item.getName();
                        selStr += " ";
                    }
                }
                mNationSel.setInfoString(selStr);
            }
        }
        else if (requestCode == Select_Province) {
            if (data != null) {
                mSelectedProvince = data.getParcelableArrayListExtra("province");
                String selStr = "";
                if (mSelectedProvince != null && mSelectedProvince.size() > 0) {
                    if (mSelectedCity != null) {
                        mSelectedCity.clear();
                        mCitySel.setInfoString("");
                        mAreaGroup.setInfoString("");
                    }
                    for (AreaData item: mSelectedProvince) {
                        selStr += item.getName();
                        selStr += " ";
                    }
                }
                mProvinceSel.setInfoString(selStr);
            }
        }
        else if (requestCode == Select_City) {
            if (data != null) {
                mSelectedCity = data.getParcelableArrayListExtra("city");
                String selStr = "";
                if (mSelectedCity != null && mSelectedCity.size() > 0) {
                    for (AreaData item: mSelectedCity) {
                        selStr += item.getName();
                        selStr += " ";
                    }
                }
                mCitySel.setInfoString(selStr);
                mAreaGroup.setInfoString(mSelectedCity.get(0).getName());
            }
        }
    }

    /***
     * 打开GPS设置
     */
    private void openGPSSettings() {
        LocationManager alm = (LocationManager) this.getSystemService(Context.LOCATION_SERVICE);
        if (alm.isProviderEnabled(android.location.LocationManager.GPS_PROVIDER)) {
            showMessage("GPS开始定位");
            doWork();
            return;
        }


        Intent intent = new Intent();
        intent.setAction(Settings.ACTION_LOCATION_SOURCE_SETTINGS);
        intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        try {
            startActivityForResult(intent, 0); //此为设置完成后返回到获取界面
        }
        catch(ActivityNotFoundException ex) {
            // The Android SDK doc says that the location settings activity
            // may not be found. In that case show the general settings.
            // General settings activity
            intent.setAction(Settings.ACTION_SETTINGS);
            try {
                startActivityForResult(intent, 0); //此为设置完成后返回到获取界面
            }
            catch (Exception e) {
                showMessage("无法开启GPS，请手动打开！");
            }
        }
    }

    private void doWork() {
//        String msg = "";

        LocationManager locationManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE);

        Criteria criteria = new Criteria();
        // 获得最好的定位效果
        criteria.setAccuracy(Criteria.ACCURACY_FINE);
        criteria.setAltitudeRequired(false);
        criteria.setBearingRequired(false);
        criteria.setCostAllowed(false);
        // 使用省电模式
        criteria.setPowerRequirement(Criteria.POWER_LOW);
        // 获得当前的位置提供者
        String provider = locationManager.getBestProvider(criteria, true);
        if (StringUtils.isEmpty(provider)) {
            showMessage("获得当前的位置失败!");
            return;
        }
        // 获得当前的位置
        Location location = locationManager.getLastKnownLocation(provider);
        if (location == null) {
            showMessage("获得当前的位置失败!");
            return;
        }


        Geocoder gc = new Geocoder(this);
        List<Address> addresses = null;
        try {
            addresses = gc.getFromLocation(location.getLatitude(), location.getLongitude(), 1);
        } catch (IOException e) {
            e.printStackTrace();
        } if (addresses.size() > 0) {
            getCityGuid(addresses.get(0).getLocality());
        }
    }

    /***
     * 通过城市ID获得城市
     * @param guidId
     */
    private void getCityByGuid(String guidId) {
        Map<String, Object> param = new HashMap<>();
        param.put("cid", guidId);

        BasicHttpClient.httpGetAsync(HttpConstant.HTTP_GET_CITY, param, new HttpCallbackHandle<GetCityGuidResp>() {
            @Override
            public void onSuccess(GetCityGuidResp obj) {
                // 成功
                if (mSelectedCity == null || mSelectedCity.size() == 0) {
                    mSelectedCity = new ArrayList<AreaData>();
                    mSelectedCity.add(obj.getGetCityByIdResult());
                    mAreaGroup.setInfoString(mSelectedCity.get(0).getName());
                }
            }

            @Override
            public void onFailure(String response) {

            }
        });
    }


    /***
     * 通过城市名称获得城市ID
     * @param cityName
     */
    private void getCityGuid (final String cityName) {
        Map<String, Object> param = new HashMap<>();
        param.put("cn", cityName);

        BasicHttpClient.httpGetAsync(HttpConstant.HTTP_GET_CITY_GUID, param, new HttpCallbackHandle<GetCityGuidResp>() {
            @Override
            public void onSuccess(GetCityGuidResp obj) {
                // 成功
                if (mSelectedCity == null || mSelectedCity.size() == 0) {
                    AreaData data = new AreaData();
                    data.setGuidId(obj.getGetCityIdResult());
                    data.setName(cityName);
                    mSelectedCity = new ArrayList<AreaData>();
                    mSelectedCity.add(data);
                    mAreaGroup.setInfoString(cityName);
                }
            }

            @Override
            public void onFailure(String response) {

            }
        });
    }

    private boolean projectInfoIsOk() {
        if (mSelectedCity == null || mSelectedCity.size() == 0) {
            showMessage("没有选择项目所在的城市！");
            return false;
        }

        if (StringUtils.isEmpty(mHouseCet.getText().toString())) {
            showMessage("项目名称不能为空！");
            return false;
        }

        if (StringUtils.isEmpty(mAreaCet.getText().toString())) {
            showMessage("户型面积必须大于0！");
            return false;
        }

        if (StringUtils.isEmpty(mNameCet.getText().toString())) {
            showMessage("业主姓名不能为空！");
            return false;
        }

        if (mDfrType == 0) {
            showMessage("请选择电辅热类型！");
            return false;
        }

        if (mPowerType == 0) {
            showMessage("请选择电源类型！");
            return false;
        }

        if (!StringUtils.isEmpty(mPhoneCet.getText().toString())) {
            if (mPhoneCet.getText().toString().length() != 11 || mPhoneCet.getText().toString().charAt(0) != '1') {
                showMessage("手机号码不正确！");
                return false;
            }
        }

        if (StringUtils.isEmpty(mPhoneCet.getText().toString())
                && StringUtils.isEmpty(mQQCet.getText().toString())
                && StringUtils.isEmpty(mWecharCet.getText().toString())
                && StringUtils.isEmpty(mEmailCet.getText().toString())) {
            showMessage("业主联系方式不能为空！");
            return false;
        }

        return true;
    }


    private boolean projectInfoIsModified() {
        ProjectInfoData projectInfoData = ProjectManager.getInstance().getProjectData();

        if (!StringUtils.isEquals(projectInfoData.getCityId(), mSelectedCity.get(0).getGuidId())) {
            return true;
        }

        if (!StringUtils.isEquals(projectInfoData.getHouse(), mHouseCet.getText().toString())) {
            return true;
        }

        if (projectInfoData.getArea() != Double.valueOf(mAreaCet.getText().toString())) {
            return true;
        }

        if (!StringUtils.isEquals(projectInfoData.getOwnerName(), mNameCet.getText().toString())) {
            return true;
        }

        if (!StringUtils.isEquals(projectInfoData.getOwnerContact(), mPhoneCet.getText().toString())) {
            return true;
        }

        if (!StringUtils.isEquals(projectInfoData.getOwnerQQ(), mQQCet.getText().toString())) {
            return true;
        }

        if (!StringUtils.isEquals(projectInfoData.getOwnerWeChar(), mWecharCet.getText().toString())) {
            return true;
        }

        if (!StringUtils.isEquals(projectInfoData.getOwnerEmail(), mEmailCet.getText().toString())) {
            return true;
        }

        if (mDfrType != projectInfoData.getDfrType()) {
            return true;
        }

        if (mPowerType != projectInfoData.getPowerType()) {
            return true;
        }

        return false;
    }

    private void createProject() {
        ProjectInfoData data = new ProjectInfoData();
        data.setCityId(mSelectedCity.get(0).getGuidId());
        data.setHouse(mHouseCet.getText().toString());
        data.setArea(Double.valueOf(mAreaCet.getText().toString()));
        data.setOwnerName(mNameCet.getText().toString());
        data.setOwnerContact(mPhoneCet.getText().toString());
        data.setOwnerQQ(mQQCet.getText().toString());
        data.setOwnerWeChar(mWecharCet.getText().toString());
        data.setOwnerEmail(mEmailCet.getText().toString());
        data.setDfrType(mDfrType);
        data.setPowerType(mPowerType);

        Map<String, Object> param = new HashMap<>();
        param.put("prjInfo", data);

        if (mProgressDlg ==  null) {
            mProgressDlg = createProgressBarDialog(this, "创建新项目中...");
        }
        mProgressDlg.show();

        BasicHttpClient.httpPutAsync(HttpConstant.HTTP_PUT_CREATE_PROJECT, AccountManager.getInstance().getToken(), param, new HttpCallbackHandle<GetProjectInfoDataResp>() {
            @Override
            public void onSuccess(GetProjectInfoDataResp obj) {
                // 成功
                loadProject(obj.getCreateResult());
                EventBus.getDefault().post(new ProjectListRefreshEvent());
            }

            @Override
            public void onFailure(String response) {
                mProgressDlg.dismiss();
                showMessage("创建项目失败，请重试！");
            }
        });
    }

    private void loadProject(String guid) {
        Map<String, Object> param = new HashMap<>();
        param.put("pid", guid);
        BasicHttpClient.httpGetAsync(HttpConstant.HTTP_GET_PROJECT_BY_GUID, AccountManager.getInstance().getToken(), param, new HttpCallbackHandle<GetProjectInfoDataResp>() {
            @Override
            public void onSuccess(GetProjectInfoDataResp obj) {
                // 成功
                ProjectManager.getInstance().setProjectData(obj.getGetProjectResult());
                mProgressDlg.dismiss();
                //跳转到第二步
                ProjectManager.getInstance().goNextStep();
                startActivity(AnnotationUtil.get(ProjectStep2Activity.class));
            }

            @Override
            public void onFailure(String response) {
                mProgressDlg.dismiss();
                showMessage("创建项目失败，请重试！");
            }
        });
    }

    private void modifyProject() {
        ProjectInfoData data = ProjectManager.getInstance().getProjectData();
        data.setCityId(mSelectedCity.get(0).getGuidId());
        data.setHouse(mHouseCet.getText().toString());
        data.setArea(Double.valueOf(mAreaCet.getText().toString()));
        data.setOwnerName(mNameCet.getText().toString());
        data.setOwnerContact(mPhoneCet.getText().toString());
        data.setOwnerQQ(mQQCet.getText().toString());
        data.setOwnerWeChar(mWecharCet.getText().toString());
        data.setOwnerEmail(mEmailCet.getText().toString());
        data.setDfrType(mDfrType);
        data.setPowerType(mPowerType);

        //特殊处理，不然会导致项目阶段不对
        data.setPhase(ProjectInfoData.PROJECT_PHASE_INPROGRESS);

        Map<String, Object> param = new HashMap<>();
        param.put("prjInfo", data);

        if (mProgressDlg ==  null) {
            mProgressDlg = createProgressBarDialog(this, "修改项目中...");
        }
        mProgressDlg.show();

        BasicHttpClient.httpPostAsync(HttpConstant.HTTP_POST_PROJECT_INFO, AccountManager.getInstance().getToken(), param, new HttpCallbackHandle<GetProjectInfoDataResp>() {
            @Override
            public void onSuccess(GetProjectInfoDataResp obj) {
                // 成功
                mProgressDlg.dismiss();
                ProjectManager.getInstance().setProjectData(obj.getModifyResult());
                if (ProjectManager.getInstance().isBindTemplate()) {
                    ProjectManager.getInstance().goNextStep();
                    startActivity(AnnotationUtil.get(ProjectStep3Activity.class));
                }
                else {
                    ProjectManager.getInstance().goNextStep();
                    startActivity(AnnotationUtil.get(ProjectStep2Activity.class));
                }
            }

            @Override
            public void onFailure(String response) {
                mProgressDlg.dismiss();
                showMessage("修改项目信息失败，请重试！");
            }
        });

    }

}
